package engine.geom
{

    public class HalfSpace
    {

		public var normal:Point3D ; // normal to boundary plane/
		public var d:Number; // eqn of half space is normal.x - d > 0
		  
		  /*
		  /** Create a half space
		  public HalfSpace(Point3d a,Point3d b,Point3d c){
		normal = b.subtract(a).cross(c.subtract(a)).normalize();
		d = normal.dot(a);
		  }
		*/
		
		/** Create a half space parallel to z axis
		*/
		public function HalfSpace( a:Point3D, b:Point3D )
		{
			normal = b.subtract(a).cross(new Point3D(0,0,1)).normalize();
			d = normal.dot(a);
		}
		
		public function inside ( p:Point3D ) : Boolean
		{
			return normal.dot(p) > d;
		}
		
		/** z coordinate of intersection of a vertical line through p and boundary plane */
		//public function zint( p:Point3D ) : Number
		//{
			//return (d - normal.x()*p.x() - normal.y()*p.y()) / normal.z();
		//}

    }
}
